package com.enumTest;

/**
 * <p>Description: [用法二：switch]</p>
 * Created on 2021/1/8
 *
 * @author <a href="mailto: 819712047@qq.com">谢振东 </a>
 * @version 1.0
 */
public class test2 {
    public static void main(String[] args) {
        Signal color = Signal.RED;
        System.out.println(color);
        test2 test2 = new test2();
        color = test2.change(color);
        System.out.println(color);
    }

    public Signal change(Signal color) {
        switch (color) {
            case RED:
                color = Signal.GREEN;
                break;
            case YELLOW:
                color = Signal.RED;
                break;
            case GREEN:
                color = Signal.YELLOW;
                break;
        }
        return color;
    }
}

enum Signal {
    GREEN, YELLOW, RED
}